package com.hmall.search.pojo;

import com.hmall.common.dto.Item;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ItemDoc {
    private Long id; //商品id
    private String name; //商品名称
    private Long price; //价格（分）
    private String image; //商品图片
    private String category; //分类名称
    private String brand; //品牌名称
    private Integer sold; //销量
    private Integer commentCount; //评论数
    private Boolean isAD; // 是否是广告

    private List<String> suggestion;//  =new ArrayList<>();


    public ItemDoc(Item item){
        // item 拷贝到 itemDoc
        BeanUtils.copyProperties(item, this);
        // 组装suggestion
        this.suggestion= Arrays.asList(this.brand, this.category);
        /*suggestion.add(item.getName());
        suggestion.add(item.getBrand());
        suggestion.add(item.getCategory());*/
    }
}
